<%@ page language="java" contentType="text/html; charset=utf-8" %>
<%@ page import="com.alibaba.fastjson.JSONArray" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="weaver.conn.RecordSet" %>
<%@ page import="com.engine.cese.duss.invoice.util.OcrUtil" %>
<%@ page import="java.util.Map" %>
<%@ page import="weaver.general.Util" %>
<%@ page import="com.alibaba.fastjson.JSONObject" %>
<jsp:useBean id="rs" class="weaver.conn.RecordSet" scope="page"/>
<jsp:useBean id="rs1" class="weaver.conn.RecordSet" scope="page"/>
<jsp:useBean id="bb" class="weaver.general.BaseBean"/>
<%
    bb.writeLog( "----FPXX.jsp----" );
    Map<String, Object> apidatas = new HashMap<String, Object>();
        try {
            boolean flag = true;
            String msg = "";
            String sql = "";
            rs.executeQuery( sql );
            while (rs.next()) {
                String fpzw = Util.null2String( rs.getString( "fpzw" ) );
                String fplx = Util.null2String( rs.getString( "fplx" ) );
                String fpdm = Util.null2String( rs.getString( "fpdm" ) );
                String fphm = Util.null2String( rs.getString( "fphm" ) );
                String fprq = Util.null2String( rs.getString( "fprq" ) );
                String bhsje = Util.null2String( rs.getString( "bhsje" ) );
                String checkCode = Util.null2String( rs.getString( "checkCode" ) );
                String purchaserName = Util.null2String( rs.getString( "gmfmc" ) );
                String sellerRegisterNum = Util.null2String( rs.getString( "sellerRegisterNum" ) );//预留电话
                bb.writeLog( String.join( "-", fplx, fpdm, fphm, fprq, bhsje, checkCode, sellerRegisterNum ) );
                if("0".equals( fplx ) ||"1".equals( fplx ) ||"11".equals( fplx )||"14".equals( fplx )||"15".equals( fplx )){
                    if ("1".equals( fpzw ) || "2".equals( fpzw )) {
                        Map<String,Object> resultMap = OcrUtil.invoicerecertify( fplx, fpdm, fphm, fprq, bhsje, checkCode, sellerRegisterNum,purchaserName );
                        flag = (boolean) resultMap.get("flag");
                        msg = (String) resultMap.get("msg");
                    }  else if ("0".equals( fpzw )) {
                        flag = false;
                        msg = "系统提示：发票已经验真通过";
                    }else {
                        flag = false;
                        msg = "系统提示：只有[认证不通过]的发票才能重新验真";
                    }
                }else {
                    flag = false;
                    msg = "系统提示：此发票不能验真";
                }
            }
            apidatas.put( "msg", msg );
            apidatas.put( "flag", flag );
            apidatas.put( "api_status", true );
        } catch (Exception e) {
            e.printStackTrace();
            apidatas.put( "api_status", false );
            apidatas.put( "error_message", "请求异常" );
        }

        out.print( JSONObject.toJSONString( apidatas ));
%>